﻿using MiniFox.Components;
using MiniFox.Platform.OAuth2;
using MiniFox.Platform.OAuth2.Models;
using MiniFox.Platform.State;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MiniFox.Platform.OAuth2
{
    /// <summary>
    /// 
    /// </summary>
    [AutoRegister, SpareComponent(typeof(AuthorizationStateManagement))]
    public interface IAuthenticationStateManagement : IStateManagement
    {
        /// <summary>
        /// a ticket id for passport token 
        /// </summary>
        string AuthTicketID
        {
            get;
            set;
        }
    }

    /// <summary>
    /// 
    /// </summary>
    public class AuthorizationStateManagement : StateManagement, IAuthenticationStateManagement
    {
        /// <summary>
        /// 
        /// </summary>
        public const string AUTH_STATE_CONTEXT = "Authorization-State-Management";
        /// <summary>
        /// 
        /// </summary>
        public AuthorizationStateManagement()
        {
            CookieStateExpires = 86400;
        }
        /// <summary>
        /// 获取令牌或将passport令牌的票据ID置入状态管理体系
        /// </summary>
        public string AuthTicketID
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        public override void Clear()
        {
            this.AuthTicketID = null;
        }
    }
}
